/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.hagopa.games.moneypool.msgs.ContentTypes.service;

/**
 *
 * @author Igor
 */
import java.nio.ByteBuffer;

public class JoinRespRecord {
    private int cid=0;
    private int namesz = 0;
    private String name ="unknown";
    public int getsz()
    {
        return (8 + this.namesz);
    }
    public void setcid(int cid)
    {
        this.cid = cid;
    }
    public int getcid()
    {
        return this.cid;
    }
    public byte[] marshallToByte()
    {
            
            ByteBuffer dataArray = ByteBuffer.allocate(512);
            dataArray.putInt(this.cid);
            dataArray.putInt(this.namesz);
            byte [] bytes = new byte[this.namesz * 8];
            try{

                dataArray.put(this.name.getBytes());
                }catch (NullPointerException e1) {
			// TODO Auto-generated catch block
			System.out.println("Failed to set bytes array");
			e1.printStackTrace();
		}
            dataArray.rewind();
            dataArray.get(bytes, 0, bytes.length);
            return bytes;
    }
    public void setname(String name)
    {
        this.name = name;
        this.namesz = name.length();
    }
    public String getname()
    {
        return this.name;
    }
}
